# ============================================================================
#	{[iXe[WPir[r؂j
# ============================================================================
include	/pic/pic.mak

# ============================================================================
#	Ώۃt@C
# ============================================================================
OBJS	=	b1hero0 b1hero1 b1hero2 b1hero3 b1hero4 b1hero5 b1hero6\
		b1hero7 b1hero8

CHRS	=	${addsuffix .chr,${OBJS}}\
		b1bg.chr bottle.chr
PALS	=	b1hero.pal b1bg.pal bottle.pal
SPTS	=	${addsuffix .spt,${OBJS}}\
		bottle.spt spgage.spt spmoji3.spt
ZSBS	=	${addsuffix .zsb,${OBJS}}

BB	=	${BTD}\b1bg.btd
B2	=	${BTD}\b1bg2.btd	# r 3*7 char
# ============================================================================
#	ŏI^[Qbg
# ============================================================================
all:	${CHRS} ${PALS} ${SPTS} ${BB} ${B2} ${ZSBS}

spt:	${SPTS}

clean:	clean_spt clean_zsb
	${cmdsplit -rm %,60,${addprefix ${CHR}\,${CHRS}}}
	${cmdsplit -rm %,60,${addprefix ${PAL}\,${PALS}}}
	-rm ${BB} ${B2}

clean_spt:
	${cmdsplit -rm %,60,${addprefix ${SPT}\,${SPTS}}}

clean_zsb:
	${cmdsplit -rm %,60,${addprefix ${ZSB}\,${ZSBS}}}

# ============================================================================
#	IȐK
# ============================================================================
b1hero.pal:	b1hero0.ccb
	nulcut -c $^ $0
	pakccb -s $0 ${PAL}\${@F}


${BB} ${B2}:	b1bg.cgb
	cbat -d -X0 -Y0 -x32 -y32 -o$3 $^
	lzss -e $3 ${BB}
	outbin -h -b32,32 ${BB}
	cbat -d -X32 -Y0 -x3 -y7 -o$3 $^
	lzss -e $3 ${B2}
	outbin -h -b3,7 ${B2}
# ----------------------------------------------------------------------------
#bottle.chr:	bottle0.csb awa01.csb awa02.csb
#	copy /b bottle0.csb+awa01.csb+awa02.csb $0
#	nulcut -s $0 $1
#	prs $1 ${CHR}\${@F}
#
#bottle.pal:	bottle0.ccb
#	nulcut -c $^ $0
#	pakccb -s $0 ${PAL}\${@F}
#
#bottle.spt:	bottle.cab btltop.cab awa1.cab awa2.cab awa3.cab
#	echo  include ${GSYS}\objtbl.h>$0.s
#	cabtbl -t -f1 $^ >>$0.s
#	as -o$0.o $0.s
#	lk -b${SPT}\${@F} /cseg:0,0 $0.o

bottle.chr bottle.pal bottle.spt:	bottle0.csb awa01.csb awa02.csb\
					bottle0.ccb bottle.cab btltop.cab\
					awa1.cab awa2.cab awa3.cab
	techo -z
	${cmdsplit techo %,60,$^}
	techo -o $0
	spcmp -j -o$1 -b0 @$0
	prs $1.chr ${CHR}\bottle.chr
	pakccb -s $1.pal ${PAL}\bottle.pal
	echo  include ${GSYS}\objtbl.h>$0.s
	cabtbl -t -f1 $1.cab >>$0.s
	as -o$0.o $0.s
	lk -b${SPT}\bottle.spt /cseg:0,0 $0.o
# -------------------------------------------------------------------------
define	tblgen
echo  include ${GSYS}\objtbl.h>$0.s
echo BANK2=0>>$0.s
cabtbl -t -f1 $^ >>$0.s
as -o$0.o $0.s
lk -b${SPT}\${@F} /cseg:0,0 $0.o
endef


b1hero0.spt:	b1hero0.cab
	${expand ${tblgen}}
b1hero1.spt:	b1hero1.cab
	${expand ${tblgen}}
b1hero2.spt:	b1hero2.cab
	${expand ${tblgen}}
b1hero3.spt:	b1hero3.cab
	${expand ${tblgen}}
b1hero4.spt:	b1hero4.cab
	${expand ${tblgen}}
b1hero5.spt:	b1hero5.cab
	${expand ${tblgen}}
b1hero6.spt:	b1hero6.cab
	${expand ${tblgen}}
b1hero7.spt:	b1hero7.cab
	${expand ${tblgen}}
b1hero8.spt:	b1hero8.cab
	${expand ${tblgen}}
